<?php

namespace App\ModelFilters;

use EloquentFilter\ModelFilter;

class NetCourseFilter extends ModelFilter
{
    /**
    * Related Models that have ModelFilters as well as the method on the ModelFilter
    * As [relationMethod => [input_key1, input_key2]].
    *
    * @var array
    */
    public $relations = [];

    public function province($v) {
        $v = is_array($v) ? $v : explode(',', $v);

        if (!empty($v)) {
            return  $this->query->where(function ($query) use ($v) {
                foreach ($v as $value) {
                    $query->orWhereRaw("CONCAT(',', province, ',') LIKE ?", [',%' . $value . '%,']);
                }
            });
        }
    }
}
